package com.jiashn.phonetoregion.controller;

import com.jiashn.phonetoregion.utils.JsonResult;
import com.jiashn.phonetoregion.utils.PhoneToRegionCsvUtil;
import com.jiashn.phonetoregion.utils.PhoneToRegionUtil;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author: jiangjs
 * @description:
 * @date: 2023/11/30 14:44
 **/
@RestController
@RequestMapping("/phone")
public class PhoneToRegionController {

    @Resource
    private PhoneToRegionCsvUtil phoneToRegionCsvUtil;

    @GetMapping("/getPhoneCarrierInfo.do/{phone}")
    public JsonResult<?> getPhoneCarrierInfo(@PathVariable("phone") String phone){
        return JsonResult.success(PhoneToRegionUtil.getPhoneCarrier(phone));
    }

    @GetMapping("/getPhoneGeoInfo.do/{phone}")
    public JsonResult<?> getPhoneGeoInfo(@PathVariable("phone") String phone){
        return JsonResult.success(PhoneToRegionUtil.getRegionInfoByPhone(phone));
    }
    @GetMapping("/getPhoneAffiliationInfo.do/{phone}")
    public JsonResult<?> getPhoneAffiliationInfo(@PathVariable("phone") String phone){
        return JsonResult.success(PhoneToRegionUtil.getPhoneAffiliationInfo(phone));
    }

    @GetMapping("/getPhoneGeoInfoByCsv.do/{phone}")
    public JsonResult<?> getPhoneGeoInfoByCsv(@PathVariable("phone") String phone){
        return JsonResult.success(phoneToRegionCsvUtil.getPhoneToRegion(phone));
    }
}
